/**********************************************************************\

 Copyright 2012 Diggory Blake

 This file is part of klip-engine

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.

\**********************************************************************/

#include "kline.h"

void kLine::updateMesh() {
	kVec2 vec = cross(normalize(_b - _a))*(_width*0.5f);
	setVertex(0, _a-vec);
	setVertex(1, _a+vec);
	setVertex(2, _b+vec);
	setVertex(3, _b-vec);
}
kLine::kLine(kEngine* engine) : kMesh2DBase(engine) {
	setMaterialRepeat(true, false);
	setMeshType(keMesh_TriangleFan);
	resize(4, 1, 1);
	setColor(kColor(1.0f, 1.0f, 1.0f, 1.0f));
	_width = 1.0f;

	setTextureCoord(0, kVec2(0.0f, 1.0f));
	setTextureCoord(1, kVec2(0.0f, 0.0f));
	setTextureCoord(2, kVec2(1.0f, 0.0f));
	setTextureCoord(3, kVec2(1.0f, 1.0f));
	updateMesh();
}
kLine::~kLine() {
}

